package com.ruoyi.web.controller.control;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.control.domain.ProducingNitrogen;
import com.ruoyi.control.service.IProducingNitrogenService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 制氮Controller
 *
 * @author ruoyi
 * @date 2024-12-03
 */
@RestController
@RequestMapping("/producingNitrogen/producingNitrogen")
public class ProducingNitrogenController extends BaseController
{
    @Autowired
    private IProducingNitrogenService producingNitrogenService;

    /**
     * 查询制氮列表
     */
    @PreAuthorize("@ss.hasPermi('producingNitrogen:producingNitrogen:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProducingNitrogen producingNitrogen)
    {
        startPage();
        List<ProducingNitrogen> list = producingNitrogenService.selectProducingNitrogenList(producingNitrogen);
        return getDataTable(list);
    }

    /**
     * 查询制氮列表-不分页
     * lqx
     */
    @PreAuthorize("@ss.hasPermi('producingNitrogen:producingNitrogen:list')")
    @GetMapping("/list1")
    public TableDataInfo list1(ProducingNitrogen producingNitrogen)
    {
        List<ProducingNitrogen> list = producingNitrogenService.selectProducingNitrogenList(producingNitrogen);
        return getDataTable(list);
    }

    /**
     * 查询制氮列表-不分页
     * lqx
     */
    @PreAuthorize("@ss.hasPermi('producingNitrogen:producingNitrogen:list')")
    @GetMapping("/list2")
    public TableDataInfo list2(ProducingNitrogen producingNitrogen)
    {
        List<ProducingNitrogen> list = producingNitrogenService.selectProducingNitrogenList(producingNitrogen);
        return getDataTable(list);
    }

    /**
     * 查询制氮列表-不分页
     * lqx
     */
    @PreAuthorize("@ss.hasPermi('producingNitrogen:producingNitrogen:list')")
    @GetMapping("/list3")
    public TableDataInfo list3(ProducingNitrogen producingNitrogen)
    {
        List<ProducingNitrogen> list = producingNitrogenService.selectProducingNitrogenList(producingNitrogen);
        return getDataTable(list);
    }

    /**
     * 导出制氮列表
     */
    @PreAuthorize("@ss.hasPermi('producingNitrogen:producingNitrogen:export')")
    @Log(title = "制氮", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProducingNitrogen producingNitrogen)
    {
        List<ProducingNitrogen> list = producingNitrogenService.selectProducingNitrogenList(producingNitrogen);
        ExcelUtil<ProducingNitrogen> util = new ExcelUtil<ProducingNitrogen>(ProducingNitrogen.class);
        util.exportExcel(response, list, "制氮数据");
    }

    /**
     * 获取制氮详细信息
     */
    @PreAuthorize("@ss.hasPermi('producingNitrogen:producingNitrogen:query')")
    @GetMapping(value = "/{tagName}")
    public AjaxResult getInfo(@PathVariable("tagName") String tagName)
    {
        return success(producingNitrogenService.selectProducingNitrogenByTagName(tagName));
    }

    /**
     * 新增制氮
     */
    @PreAuthorize("@ss.hasPermi('producingNitrogen:producingNitrogen:add')")
    @Log(title = "制氮", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProducingNitrogen producingNitrogen)
    {
        return toAjax(producingNitrogenService.insertProducingNitrogen(producingNitrogen));
    }

    /**
     * 修改制氮
     */
    @PreAuthorize("@ss.hasPermi('producingNitrogen:producingNitrogen:edit')")
    @Log(title = "制氮", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProducingNitrogen producingNitrogen)
    {
        return toAjax(producingNitrogenService.updateProducingNitrogen(producingNitrogen));
    }

    /**
     * 删除制氮
     */
    @PreAuthorize("@ss.hasPermi('producingNitrogen:producingNitrogen:remove')")
    @Log(title = "制氮", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tagNames}")
    public AjaxResult remove(@PathVariable String[] tagNames)
    {
        return toAjax(producingNitrogenService.deleteProducingNitrogenByTagNames(tagNames));
    }
}
